package com.maoguo.user.service.impl;

import com.maoguo.org.mapper.OrgMapper;
import com.maoguo.org.model.Organize;
import com.maoguo.org.service.OrgService;
import com.maoguo.user.mapper.UserMapper;
import com.maoguo.user.model.User;
import com.maoguo.user.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService{
    @Resource
    private UserMapper userMapper;
    @Resource
    private OrgService orgService;
    @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED) // 有事务则加入,没有则建立
    public void saveUser(User user) {
        System.out.println("save user");
        userMapper.insert(user);
        Organize organize=new Organize();
        organize.setId(1l);
        orgService.save(organize);
    }

    public Organize findOrg(String userId) {
        System.out.println("findOrg");
        return null;
    }

    @Override
    public long updateUser(String name) {
        return  userMapper.selectById();
    }
}
